package leetcode_core.leetcode_3;

import org.junit.Test;

public class RemoveDuplicates {
    public int removeDuplicates(int[] nums) {
        if(nums.length  == 1){
            return 1;
        }
        int slow = 0,fast = 1;
        int val = nums[slow];
        while (fast < nums.length){
            int cur = nums[fast];
            if(cur == val){
                fast++;
                continue;
            }
            slow++;fast++;
            nums[slow] = cur;
            val = cur;
        }
        return slow+1;
    }

    @Test
    public void test(){
        System.out.println(removeDuplicates(new int[]{1,1,2}));
    }
}
